Skip to content

feat: support configurable Electron backend root - #153

Merged
regnull merged 3 commits into
mainfrom
feat/STO-root-directory-support
Sep 25, 2026
Merged

regnull merged 3 commits into
mainfrom
feat/STO-root-directory-support

Conversation

@regnull

@regnull regnull commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add an optional backend root-directory argument for Electron development and packaged startup.
  • Resolve default thread workspace and SQLite database paths beneath the supplied root.
  • Preserve explicit WORKSPACE_ROOT and DATABASE_URL overrides and existing no-root behavior.

Problem

Electron callers need to select the application/project root at launch, but backend defaults were tied to the process working directory or Electron user-data conventions. The launcher had no way to forward a caller-selected root.

Solution

  • openbot.cli accepts --root-directory and exposes it to settings as OPENBOT_ROOT_DIRECTORY.
  • Settings applies the root only when workspace/database values remain at their defaults:
    • workspace: <root>
    • database: <root>/.openbot/openbot.db
  • Electron development and packaged backend scripts forward the root safely.
  • Make supports ROOT_DIRECTORY=/path make electron.
  • Regression tests cover supplied-root defaults, explicit overrides, unchanged defaults, and launcher forwarding.

Files changed

File Change
backend/openbot/cli.py Parse and export the root argument.
backend/openbot/config.py Apply root-derived defaults without overriding explicit configuration.
backend/tests/test_config.py Add root/default/override regression coverage.
scripts/electron-dev.sh Forward root to the development backend.
scripts/electron-backend.sh Forward packaged root and avoid user-data defaults when supplied.
frontend/electron/main.cjs Pass configured root environment through packaged startup.
frontend/electron/main.test.ts Verify root forwarding.
Makefile Add ROOT_DIRECTORY forwarding for Electron.

Validation

  • make lint (Ruff, Oxlint, client-boundary check): passed; existing Oxlint warnings only.
  • make test: passed (460 backend tests, frontend tests, typecheck).
  • make build: passed.
  • Focused config and Electron tests: passed.

Design notes

Explicit environment configuration remains authoritative. The root is a defaulting mechanism rather than a forced rewrite, so browser/development startup without a root and custom database/workspace deployments remain unchanged.

@regnull regnull left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested.

  1. BLOCKER — backend/openbot/config.py:94-99: Root fallback detects whether overrides were explicit by comparing their parsed values to the defaults. This violates the stated “explicit WORKSPACE_ROOT and DATABASE_URL overrides remain authoritative” contract whenever an explicit override equals the default (for example WORKSPACE_ROOT=./workspace or DATABASE_URL=sqlite+aiosqlite:///./.openbot/openbot.db): the validator still replaces it with the supplied root. Use Pydantic's field-set/source information (or equivalent pre-validation) to distinguish omitted fields from explicitly supplied values, and add regression tests for both explicit-default cases.

  2. NIT — Makefile:4: ELECTRON_ROOT_ARGS interpolates ROOT_DIRECTORY unquoted. A root path containing spaces is split into multiple positional arguments, so electron-dev.sh forwards only the first word as the root. Please either preserve argument boundaries (or document/reject such paths) and add a forwarding test if this option is intended to support normal filesystem paths.

— Reviewer - @Reviewer

@regnull regnull left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to merge: PR #153 has addressed the previously identified configuration override and Makefile argument-boundary issues. The updated diff preserves explicitly supplied WORKSPACE_ROOT/DATABASE_URL (including values equal to defaults), forwards root paths safely through development and packaged startup, and adds regression coverage. CI is green at the reviewed head f543d7206ec17b96ff4eb9287a038bd790c25425.

— Reviewer - @Reviewer

@regnull regnull left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to merge.\n\nRe-reviewed the exact head 63dca69. The cancellation race fix snapshots the task reference before the null check and cancels that stable reference; root-directory propagation, explicit override preservation, quoting, and regression coverage remain correct. CI is green.\n\n— Reviewer - @Reviewer

@regnull
regnull merged commit 3d4b72f into main Sep 25, 2026
4 checks passed
@regnull
regnull deleted the feat/STO-root-directory-support branch September 25, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant